/**
 * 
 */
package com.luck.emp.common;

import java.sql.Types;
import java.util.HashMap;
import java.util.Map;

import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.SqlOutParameter;
import org.springframework.jdbc.core.SqlParameter;
import org.springframework.jdbc.object.StoredProcedure;

/**
 * 生成供应商编号
 *
 */
public class SpOrderNoFour extends StoredProcedure {
	private final static String STORE_PROCEDURE_NAME = "PKG_BILL_NO.MAKE_ORDER_NO_FOUR";
	
	/**
	 * 编译存储过程
	 * @param jdbcTemplate
	 */
	public SpOrderNoFour(JdbcTemplate jdbcTemplate) {
		super(jdbcTemplate, STORE_PROCEDURE_NAME);
		declareParameter(new SqlParameter("P_DEPT_CODE",Types.VARCHAR));
		declareParameter(new SqlParameter("P_ORDER_TYPE",Types.VARCHAR));
		declareParameter(new SqlOutParameter("P_ORDER_NO",Types.VARCHAR));
		compile();
	}
	
	/**
	 * 执行存储过程
	 * @param deptCode
	 * @return
	 */
	public String execute(String deptCode, String orderType){
		 Map params = new HashMap();
		 params.put("P_DEPT_CODE", deptCode);
		 params.put("P_ORDER_TYPE", orderType);
		 Map result = super.execute(params);
		 return (String)result.get("P_ORDER_NO");
	 }
}
